/*
 * Copyright 2009 Armando Blancas
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package taskgraph.tasks;

import java.util.List;
import java.util.concurrent.AbstractExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * Task Executor Service for graphs.
 * 
 * This is a simple executor service that satisfies these requirements:
 * (a) Every task submitted is scheduled to run on a new thread.
 * (b) Threads stop running when their task is done.
 * (c) No tasks are queued nor is there a thread pool to pick them up.
 * 
 * These rules ensure that the whole graph will be up and running, as it
 * needs to be. Also, there's no life-cycle management required from
 * client code, as it is the case with thread pools that must be shutdown.
 *  
 * @author Armando Blancas
 */
/*package*/ class TaskExecutor extends AbstractExecutorService {

	@Override
	public boolean awaitTermination(long timeout, TimeUnit unit)
	throws InterruptedException {
		return false;
	}

	@Override
	public void execute(Runnable command) {
		new Thread(command).start();
	}

	@Override
	public boolean isShutdown() {
		return false;
	}

	@Override
	public boolean isTerminated() {
		return false;
	}

	@Override
	public void shutdown() {
	}

	@Override
	public List<Runnable> shutdownNow() {
		return null;
	}

}
